import axios from "axios";

export const request = axios.create({
  baseURL: import.meta.env.VITE_API,
  timeout: 99999999999,
});

request.interceptors.request.use((config) => {
  let t: string | null;
  if ((t = localStorage.getItem("token"))) {
    config.headers["Authorization"] = t;
  }
  return config;
});

request.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default request;
